#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
# sys.path.append('/opt/work/caffe/python')
sys.path.insert(0, '.')

import os


old_file_list = r'/rootfs/media/kasim/DataSet/Record2/file_list.org.txt'
new_file_list = r'/rootfs/media/kasim/DataSet/Record2/file_list.txt'
diff_file_list = r'/rootfs/media/kasim/DataSet/Record2/file_list.diff.txt'
# old_file_list = r'/rootfs/media/kasim/DataSet/RecordEx/one_person_face_video_list.txt'
# new_file_list = r'/rootfs/media/kasim/DataSet/Record/one_person_face_video_list.txt'
# diff_file_list = r'/rootfs/media/kasim/DataSet/Record/one_person_face_video_list.diff.txt'


def main():
    old_file_set = set()
    with open(old_file_list, 'r') as file:
        for line in file.readlines():
            file_name = line.split()[0].strip()
            old_file_set.add(file_name)

    file_count = 0
    with open(new_file_list, 'r') as file:
        with open(diff_file_list, 'w') as out_file:
            for line in file.readlines():
                file_name = line.split()[0].strip()
                if file_name in old_file_set:
                    continue
                out_file.write(line)
                file_count += 1
        os.system('chmod a+wr {}'.format(diff_file_list))
        print('Diff File Count:', file_count)


if __name__ == '__main__':
    main()